#include <stdio.h>

/*
 * 确定组合表达式的类型
 */

void func(char * a, int i)
{
	a[i] = '\n';
	a[i+1] = 0;
}


int main()
{
	static char buff[] = "Hello,xiaozhi";

	func(&buff[0], 5);

	printf("%s\n", buff);

	return 0;
}

#if 0

/*
 * intel
 */
0000000000001149 <func>:
    1149:	f3 0f 1e fa          	endbr64 
    114d:	55                   	push   %rbp
    114e:	48 89 e5             	mov    %rsp,%rbp
    1151:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    1155:	89 75 f4             	mov    %esi,-0xc(%rbp)	// (rbp-0xc)=esi
    1158:	8b 45 f4             	mov    -0xc(%rbp),%eax	// eax=(rbp-0xc)
    115b:	48 63 d0             	movslq %eax,%rdx	// rdx=eax
    115e:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rpb-0x8)
    1162:	48 01 d0             	add    %rdx,%rax	// rax+=rdx
    1165:	c6 00 0a             	movb   $0xa,(%rax)	// (rax)=0xa
    1168:	8b 45 f4             	mov    -0xc(%rbp),%eax	// eax=(rbp-0xc)
    116b:	48 98                	cltq   
    116d:	48 8d 50 01          	lea    0x1(%rax),%rdx	// rdx=(rax+0x1)
    1171:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    1175:	48 01 d0             	add    %rdx,%rax	// rax+=rdx
    1178:	c6 00 00             	movb   $0x0,(%rax)	// (rax)=0
    117b:	90                   	nop
    117c:	5d                   	pop    %rbp
    117d:	c3                   	retq   

000000000000117e <main>:
    117e:	f3 0f 1e fa          	endbr64 
    1182:	55                   	push   %rbp
    1183:	48 89 e5             	mov    %rsp,%rbp
    1186:	be 05 00 00 00       	mov    $0x5,%esi
    118b:	48 8d 3d 7e 2e 00 00 	lea    0x2e7e(%rip),%rdi        # 4010 <buff.2319>
    1192:	e8 b2 ff ff ff       	callq  1149 <func>
    1197:	48 8d 3d 72 2e 00 00 	lea    0x2e72(%rip),%rdi        # 4010 <buff.2319>
    119e:	e8 ad fe ff ff       	callq  1050 <puts@plt>
    11a3:	b8 00 00 00 00       	mov    $0x0,%eax
    11a8:	5d                   	pop    %rbp
    11a9:	c3                   	retq   
    11aa:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)

/*
 * arm
 */
000000000040055c <func>:
  40055c:	d10043ff 	sub	sp, sp, #0x10
  400560:	f90007e0 	str	x0, [sp, #8]	// [sp+8]=x0
  400564:	b90007e1 	str	w1, [sp, #4]	// [sp+4]=w1
  400568:	b98007e0 	ldrsw	x0, [sp, #4]	// x0=[sp+4]
  40056c:	f94007e1 	ldr	x1, [sp, #8]	// x1=[sp+8]
  400570:	8b000020 	add	x0, x1, x0	// x0=x1+x0
  400574:	52800141 	mov	w1, #0xa                   	// #10
  400578:	39000001 	strb	w1, [x0]	// [x0]=w1
  40057c:	b98007e0 	ldrsw	x0, [sp, #4]	// x0=[sp+4]
  400580:	91000400 	add	x0, x0, #0x1	// x0=x0+1
  400584:	f94007e1 	ldr	x1, [sp, #8]	// x1=[sp+8]
  400588:	8b000020 	add	x0, x1, x0	// x0=x1+x0
  40058c:	3900001f 	strb	wzr, [x0]	// [x0]=0
  400590:	d503201f 	nop
  400594:	910043ff 	add	sp, sp, #0x10
  400598:	d65f03c0 	ret

000000000040059c <main>:
  40059c:	a9bf7bfd 	stp	x29, x30, [sp, #-16]!
  4005a0:	910003fd 	mov	x29, sp
  4005a4:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  4005a8:	9100c000 	add	x0, x0, #0x30	// x0=411030
  4005ac:	528000a1 	mov	w1, #0x5                   	// #5
  4005b0:	97ffffeb 	bl	40055c <func>	// func(x0, w1)
  4005b4:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  4005b8:	9100c000 	add	x0, x0, #0x30
  4005bc:	97ffffa5 	bl	400450 <puts@plt>
  4005c0:	52800000 	mov	w0, #0x0                   	// #0
  4005c4:	a8c17bfd 	ldp	x29, x30, [sp], #16
  4005c8:	d65f03c0 	ret
  4005cc:	00000000 	.inst	0x00000000 ; undefined

#endif
